<?php 
	if ((!defined("ADMIN-AREA")) || (!in_array(SHOWVIEW,$_SESSION['access']))) {
		die("No data");
	} else {
		unset($_SESSION['access']);
	}
	
	include_once "modul/funct_stat.php";

	if (ACT=="edit") {
		$arr1 = array("<fieldset","<input","</fieldset","<text","</text","<legend","</legend","<label","</label","<form","</form","<script","<?php","<%","<!--","<link","<style","</scr","</link","</code","<pre","/pre>");
		$arr2 = array("&lt;fieldset","&lt;input","&lt;/fieldset","&lt;text","&lt;/text","&lt;legend","&lt;/legend","&lt;label","&lt;/label","&lt;form","&lt;/form","&lt;script","&lt;?php","&lt;%","&lt;!--","&lt;link","&lt;a","&lt;/scr","&lt;link","&lt;code","<div align=\"center\"><pre style=\"position:relative; width:450px; overflow:auto; text-align:left;\"","/pre></div>");
		$kode = (int) $_GET['kode'];
		$sql1 = "SELECT * FROM tbl_content WHERE idx='".$kode."' AND tipe LIKE 'dinamis-%' LIMIT 1";
		$qry1 = mysql_query($sql1);
		while ($row1 = mysql_fetch_object($qry1)) {
			$judul = $row1->judul;
			$isi = explode("[break]",str_replace($arr1,$arr2,$row1->isi));
			$tipe = explode("-",$row1->tipe);
			$subkategoriX = $tipe[1];
			$kota = $tipe[2];

			$foto1 = $isi[0];
			$foto2 = $isi[1];
			$foto3 = $isi[2];
			$header_c = $row1->header_c;
			if (($row1->status)==1) {
				$pubx = "checked";
			};
		};
		
		$form_stat = "Edit";
	} else {
		$form_stat = "Input";
	}
	
	if ((ACT=="tambah") || (ACT=="edit")) {
?>
<form action="<?php echo $path; ?>ver_mj.php?show=<?php echo SHOW; ?>&amp;showview=<?php echo SHOWVIEW; ?>" method="post" enctype="multipart/form-data" name="form1" onsubmit="MM_validateForm('<?php echo $MJ_TITLE; ?>','','R','<?php echo $MJ_CONTENT; ?>','','R');return document.MM_returnValue">
  <table width="75%" border="0" align="center" cellpadding="4" cellspacing="1">
    <tr valign="top"> 
      <td width="21%" valign="middle" nowrap> <div align="right"><?php echo $MJ_TITLE; ?></div></td>
      <td width="5%" valign="middle"> <div align="center">:</div></td>
      <td width="74%" valign="middle"> <div align="left"> 
          <input name="judul" id="<?php echo $MJ_TITLE; ?>" type="text" size="50" value="<?php echo $judul; ?>" class="input-title" />
        </div></td>
    </tr>
    <tr valign="top"> 
      <td nowrap> <div align="right"><?php echo $MJ_CONTENT; ?></div></td>
      <td> <div align="center">:</div></td>
      <td><div align="left"> 
          <a href="javascript:toggleEditor('isi');">Toggle Editor</a><br />
          <textarea name="isi" cols="65" rows="15" wrap="physical" id="isi"><?php echo $header_c; ?></textarea>
      </div></td>
    </tr>
    <tr valign="top"> 
      <td nowrap> <div align="right"><?php echo $MJ_SUBCAT; ?></div></td>
      <td> <div align="center">:</div></td>
      <td> <div align="left">
      	<select name="subkategori" id="Sub Kategori">
					<?php
	  	echo subkategori(0,0,$subkategoriX,$kode_kat," AND tipe LIKE '%menu'");
	  ?>
				</select>
        <label>
          - <?php echo $MJ_UPDATE_URl; ?>
          <input name="url" type="checkbox" id="URl" value="1"  />
        </label>
      </div></td>
    </tr>
    <tr valign="top"> 
      <td> <div align="right"><?php echo $MJ_PUBLISH; ?></div></td>
      <td> <div align="center">:</div></td>
      <td> <div align="left">
        <input name="publish" type="checkbox" id="publish" value="ya" <?php echo $pubx; ?> />
      <?php echo $DEV_YES; ?></div></td>
    </tr>
    <tr valign="top"> 
      <td> <div align="right"></div></td>
      <td> <div align="center"></div></td>
      <td> <div align="left">
        <input type="submit" name="submit" id="submit" value="<?php echo $DEV_CTRL_SUBMIT; ?>" />
          <input type="reset" name="Reset" value="<?php echo $DEV_CTRL_RESET; ?>" />
          <input name="act_ver" type="hidden" id="act_ver" value="<?php echo strtolower($form_stat); ?>">
          <input name="kode" type="hidden" id="kode" value="<?php echo (int) $kode; ?>">
      </div></td>
    </tr>
  </table>
</form>
<?php
	} else {
		echo $queryData->cari_form($MJ_SEARCH);
		$caridata = $queryData->cari_padaku("","","AND (`judul` REGEXP '^[cari]' OR header_c REGEXP '^[cari]' OR isi REGEXP '^[cari]')");
?>
<table align="center" cellpadding="4" cellspacing="2" class="imagesSUB">
  <tr> 
    <th width="30" height="30" class="imagesSUB"><div align="center"><?php echo $MJ_ID; ?></div></th>
    <th width="200" class="imagesSUB"><div align="center"><?php echo $MJ_TITLE; ?></div></th>
    <th width="100" class="imagesSUB"><div align="center"><?php echo $MJ_SUBCAT; ?></div></th>
    <th width="75" class="imagesSUB"><div align="center"><?php echo $MJ_AUTHOR; ?></div></th>
    <th width="100" class="imagesSUB"> <div align="center"><?php echo $MJ_DATE; ?></div></th>
    <th width="50" class="imagesSUB"><div align="center"><?php echo $MJ_PUBLISH; ?></div></th>
    <th width="50" class="imagesSUB"><div align="center"><?php echo $DEV_ACTION; ?></div></th>
  </tr>
<?php	
		if (isset($_SESSION['isroot'])) {
			$sql1 = "SELECT * FROM tbl_content WHERE tipe LIKE 'dinamis-%' ".$caridata." LIMIT ".$limitdown.",10";	
		} else {
			$sql1 = "SELECT * FROM tbl_content WHERE tipe LIKE 'dinamis-%' ".$caridata." LIMIT ".$limitdown.",10";	
		}
		//echo $sql1;
		$qry1 = mysql_query($sql1);
		$numrow = mysql_num_rows($qry1);
		$num = 1;
		$x = 1;
		if ($numrow==0) {
			echo '<tr><th colspan="7">'.$DEV_NO_DATA.'</th></tr>';
		} else {
			while ($row1 = mysql_fetch_object($qry1)) {
				$tipe = explode("-",$row1->tipe);
				$data = $x % 2;
				if ($data==0) {
					$dataX = "ganjil";
				} else {
					$dataX = "genap";
				} 
?>
  <tr valign="top" class="<?php echo $dataX; ?>" onmouseover="setBG('bg<?php echo $x; ?>','#FFFFDD')" onmouseout="setBG('bg<?php echo $x; ?>','')" id="bg<?php echo $x; ?>"> 
    <td><div align="right"><?php echo $row1->idx; ?></div></td>
    <td><div align="left"><?php if (strlen($row1->judul)>30) echo substr($row1->judul,0,30)."..."; else echo $row1->judul; ?></div></td>
    <td><div align="center"><?php echo $queryData->selek1("ikadir_kat","id_dirkat='".$tipe[1]."'")->dir_kat; ?></div></td>
    <td nowrap="nowrap"><div align="left"><?php echo $queryData->cekUser($row1->author); ?></div></td>
    <td nowrap="nowrap"><div align="left"><?php echo $queryData->tanggalan($row1->tanggal,true);?></div></td>
    <td><div align="center"><?php (($row1->status)==1) ? print "<img src=\"images/ico_check.gif\" width=\"16\" height=\"16\"></div></td>" : print "<img src=\"images/ico_delete.gif\" width=\"16\" height=\"16\"></div></td>"; ?></div></td>
<?php 
		echo $queryData->ctrl_data('','index.php?show='.SHOW.'&showview='.SHOWVIEW.'&act=edit&kode='.$row1->idx,$path.'ver_mj.php?show='.SHOW.'&amp;showview='.SHOWVIEW.'&amp;kode='.$row1->idx.'&amp;act_ver=Hapus'); ?>
</div>
  </tr>
<?php 
  				$num++;
  				$x++;
			}
		}
?>
</table>
<div align="center"><?php echo $queryData->next_prev($num,$pages_syarat,$limitdown); ?></div>
<?php
	}
?>